import { http } from '@/utils/http'
import { Address } from './type'
// 获取地址列表
export const fetchAddressList = (p: Pagination) =>
  http.get<Address[]>('/shopapi/user_address/lists', p)

// 获取地址
export const fetchAddress = (id) => http.get<Address[]>('/shopapi/user_address/detail', { id })

// 设置默认地址
export const setDefaultAddress = (id: number) =>
  http.post<any>('/shopapi/user_address/setDefault', { id })

// 删除地址
export const deleteAddress = (id: number) => http.post<any>('/shopapi/user_address/del', { id })

// 添加地址
export const addAddress = <D>(data: D) => http.post<any>('/shopapi/user_address/add', data)

// 编辑地址
export const editAddress = <D>(data: D) => http.post<any>('/shopapi/user_address/edit', data)

// 省市区名称转id
export const fetchCityId = <D>(data: D) => http.get<any>('/shopapi/user_address/handleRegion', data)
